{extend name='comm/base' /}

{block name='header'}
{include file='comm/header'}
{/block}
{block name='slider'}
{include file='comm/slider'}
{/block}

{block name='main'}
<div class="main-content">
    <div class="main-content-inner">
        <div class="breadcrumbs ace-save-state" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="{:url('admin.index')}">首页</a>
                </li>
                <li class="active">意见反馈管理</li>
            </ul><!-- /.breadcrumb -->
        </div>

        <div class="page-content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="row">
                        <div class="col-xs-12">
                            <!--导入导出-->
                            <div class="space"></div>
                            <div class="table-header">
                                意见反馈管理
                            </div>

                            <!-- div.table-responsive -->

                            <!-- div.dataTables_borderWrap -->
                            <div>

                                <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>内容</th>
                                        <th>反馈人</th>
                                        <th>反馈来源</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {volist name='list' id='feedback'}
                                    <tr>
                                        <td class="center">{$feedback.id}</td>
                                        <td>
                                            {if(mb_strlen($feedback.opinion)>30)}
                                            {$feedback.opinion|substr=0,50} ...
                                            {else /}
                                            {$feedback.opinion}
                                            {/if}
                                        </td>
                                        <td>{$feedback.user.nickname}</td>
                                        <td>
                                            {eq name='feedback.back_type' value=1}
                                            用户端
                                            {else/}
                                            跑男端
                                            {/eq}
                                        </td>
                                        <td>{$feedback.create_time|date='Y-m-d H:i:s'}</td>
                                        <td>
                                            <div class="hidden-sm hidden-xs action-buttons">
                                                <a class="grey" data-id="{$feedback.id}" data-toggle="modal"
                                                   data-target="#myModal">
                                                    <i class="ace-icon fa fa-search-plus bigger-130"></i>
                                                </a>
                                                详情
                                            </div>

                                            <div class="hidden-md hidden-lg">
                                                <div class="inline pos-rel">
                                                    <button class="btn btn-minier btn-yellow dropdown-toggle"
                                                            data-toggle="dropdown" data-position="auto">
                                                        <i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
                                                    </button>

                                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                                        <li>
                                                            <a class="tooltip-info" data-rel="tooltip"
                                                               title="View">
                                                                    <span class="grey" data-id="{$feedback.id}" data-toggle="modal"
                                                                          data-target="#myModal">
                                                                        <i class="ace-icon fa fa-search-plus bigger-120"></i>
                                                                    </span>
                                                            </a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    {/volist}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <!-- PAGE CONTENT ENDS -->
                    <div class="data-paginate">
                        <div class="total"> 共{$list->total()}条记录;</div>
                        <div class="p_paginate">{$list->render()|raw}</div>
                    </div>
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">反馈详情</h4>
                    </div>
                    <div class="modal-body" id="detail">

                    </div>
                    <!--                    <div class="modal-footer">-->
                    <!--                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                    <!--                        <button type="button" class="btn btn-primary">Save changes</button>-->
                    <!--                    </div>-->
                </div>
            </div>
        </div>
    </div>
</div><!-- /.main-content -->
{/block}

{block name='footer'}
{include file='comm/footer'}
{/block}
{block name='script'}
<!--[if !IE]> -->
<script src="__ace_js__/jquery-2.1.4.min.js"></script>

<!-- <![endif]-->

<!--[if IE]>
<script src="__ace_js__/jquery-1.11.3.min.js"></script>
<![endif]-->
<script type="text/javascript">
    if ('ontouchstart' in document.documentElement) document.write("<script src='__ace_js__/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="__ace_js__/bootstrap.min.js"></script>

<!-- page specific plugin scripts -->
<script src="__ace_js__/jquery.dataTables.min.js"></script>
<script src="__ace_js__/jquery.dataTables.bootstrap.min.js"></script>
<script src="__ace_js__/dataTables.buttons.min.js"></script>
<script src="__ace_js__/buttons.flash.min.js"></script>
<script src="__ace_js__/buttons.html5.min.js"></script>
<script src="__ace_js__/buttons.print.min.js"></script>
<script src="__ace_js__/buttons.colVis.min.js"></script>
<script src="__ace_js__/dataTables.select.min.js"></script>

<!-- ace scripts -->
<script src="__ace_js__/ace-elements.min.js"></script>
<script src="__ace_js__/ace.min.js"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">

    $('.grey').on('click', function () {
        var id = $(this).data('id');
        $.ajax({
            url: "{:url('admin.feedback.detail')}",
            type: 'get',
            dataType: 'json',
            data: {id: id},
            success: function (json) {
                var data = json.data;
                if(!isEmpty(data)){
                    var str ='';
                    str+= '<table class="table table-striped">';
                    str += '<tr>';
                        str += '<th>ID</th>';
                        str += '<td>'+data.id+'</td>';
                    str += '</tr>';
                    str += '<tr>';
                        str += '<th>内容</th>';
                        str += '<td>'+data.opinion+'</td>';
                    str += '</tr>';
                    if(!isEmpty(data.img_url)){
                        str += '<tr>';
                        str += '<th>图片</th>';
                        str += '<td>';
                        $.each(data.img_url, function (index, url) {
                            str+='<img  height="auto" width="150px" src="'+url+'">';
                        });
                        str+='</td>';
                        str += '</tr>';
                    }
                    str += '<tr>';
                        str += '<th>反馈人</th>';
                        str += '<td>'+data.user.nickname+'</td>';
                    str += '</tr>';

                    str += '<tr>';
                        str += '<th>反馈来源</th>';
                        str += '<td>'+data.back_type+'</td>';
                    str += '</tr>';
                    str += '<tr>';
                        str += '<th>创建时间</th>';
                        str += '<td>'+data.create_at+'</td>';
                    str += '</tr>';
                    str+='</table>';
                    $('#detail').html(str);
                }
            }
        })
    })


    function isEmpty(obj){
        for(var key in obj){
            if(key){
                return false
            }
        }
        return true
    }

        jQuery(function ($) {
        //initiate dataTables plugin
        var myTable =
            $('#dynamic-table')
                .DataTable({
                    bAutoWidth: false,
                    "aoColumns": [
                        {"bSortable": false},
                        null, null, null, null,
                        {"bSortable": false}
                    ],
                    "aaSorting": [],
                });

        $.fn.dataTable.Buttons.defaults.dom.container.className = 'dt-buttons btn-overlap btn-group btn-overlap';

        //style the message box
        var defaultCopyAction = myTable.button(1).action();
        myTable.button(1).action(function (e, dt, button, config) {
            defaultCopyAction(e, dt, button, config);
            $('.dt-button-info').addClass('gritter-item-wrapper gritter-info gritter-center white');
        });

        var defaultColvisAction = myTable.button(0).action();
        myTable.button(0).action(function (e, dt, button, config) {

            defaultColvisAction(e, dt, button, config);


            if ($('.dt-button-collection > .dropdown-menu').length == 0) {
                $('.dt-button-collection')
                    .wrapInner('<ul class="dropdown-menu dropdown-light dropdown-caret dropdown-caret" />')
                    .find('a').attr('href', '#').wrap("<li />")
            }
            $('.dt-button-collection').appendTo('.tableTools-container .dt-buttons')
        });

        setTimeout(function () {
            $($('.tableTools-container')).find('a.dt-button').each(function () {
                var div = $(this).find(' > div').first();
                if (div.length == 1) div.tooltip({container: 'body', title: div.parent().text()});
                else $(this).tooltip({container: 'body', title: $(this).text()});
            });
        }, 500);


        $(document).on('click', '#dynamic-table .dropdown-toggle', function (e) {
            e.stopImmediatePropagation();
            e.stopPropagation();
            e.preventDefault();
        });

    })
</script>
{/block}






